package testy;

import java.util.ArrayList;
import java.util.Random;
import java.util.*;

import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;


public class Simulator extends JFrame
{

    //Variabler
    static ArrayList<Double> total = new ArrayList<Double>();
    static ArrayList<Double> heating = new ArrayList<Double>();
    static ArrayList<Double> lightning = new ArrayList<Double>();
    static ArrayList<Double> waterHeating = new ArrayList<Double>();
    static ArrayList<Double> equipment = new ArrayList<Double>();

    
    public static void main(String[] args) 
    {
    	House hus = new House(2, 120);
        
//******************************************************************************        
        //henter informasjon fra forskjellige hus deler
        heating = hus.calcHeating();
        lightning = hus.calcIllumination();
        waterHeating = hus.calcWaterHeating();
        equipment = hus.calcTechEquipment();

        for (int i = 0; i < 25; i++)
            total.add(heating.get(i) + lightning.get(i) + waterHeating.get(i) + equipment.get(i));    //total strøm forbruk

        
//******************************************************************************        
        //Skriver informasjon til consol
        System.out.println("Hus oppvarming per time");
        System.out.println(heating);

        System.out.println("Hus belysning per time");
        System.out.println(lightning);
        
        System.out.println("Oppvarming av vann per time");
        System.out.println(waterHeating);
        
        System.out.println("House equipment");
        System.out.println(equipment);
        
        System.out.println("Total energy:");
        System.out.println(total);
        
//******************************************************************************        
        //Tegner informasjon på graph
        XYSeriesCollection grafVerdier = new XYSeriesCollection();
        Graph graf = new Graph("Day demonstaration", total, grafVerdier);
        
        grafVerdier.addSeries(graf.xySeries(total, "Total power use"));
        grafVerdier.addSeries(graf.xySeries(heating, "House heating"));
        grafVerdier.addSeries(graf.xySeries(lightning, "House illumination"));
        grafVerdier.addSeries(graf.xySeries(waterHeating, "Water heating"));
        grafVerdier.addSeries(graf.xySeries(equipment, "House equipment"));
        
        graf.pack();
        graf.setVisible(true);
               
    }//end of main
}//end of Simulator
